﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Security.Policy;
using System.Threading.Tasks;
using System.Xml.Linq;
using CoreShop.Library;
using CoreShop.Model;
using CoreShop.Model.UI;
using CoreShop.Repository;
using Newtonsoft.Json;
using SqlSugar;


namespace CoreShop.Services
{
    /// <summary>
    /// 接口实现
    /// </summary>
    public class sysrecordentityServices : Repository<sysrecordentity>, IsysrecordentityServices
    {
        #region 实现重写增删改查操作==========================================================

        /// <summary>
        /// 重写异步插入方法
        /// </summary>
        /// <param name="entity">实体数据</param>
        /// <returns></returns>
        public bool InsertAsync(sysrecordentity entity)
        {
            return base.Change<sysrecordentity>().Insert(entity);
        }
        public bool InsertOrUpdate(List<sysrecordentity> entity)
        {
            return base.InsertOrUpdate(entity);
        }
        /// <summary>
        /// 重写异步更新方法方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateAsync(sysrecordentity entity)
        {
            return base.Change<sysrecordentity>().Update(a => new sysrecordentity()
            {
                tenantId = entity.tenantId,
                recordName = entity.recordName,
                recordTime = entity.recordTime,
            }, a => a.id == entity.id);
        }

        /// <summary>
        /// 重写异步更新方法方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateAsync(List<sysrecordentity> entity)
        {
            bool returnKey = true;
            foreach (var item in entity)
            {
                returnKey = base.Change<sysrecordentity>().Update(a => new sysrecordentity()
                {
                    tenantId = item.tenantId,
                    recordName = item.recordName,
                    recordTime = item.recordTime,
                }, a => a.id == item.id);
            }
            return returnKey;
        }
               
        #endregion

        #region 获取缓存的所有数据==========================================================

        /// <summary>
        /// 获取缓存的所有数据
        /// </summary>
        /// <returns></returns>
        public List<sysrecordentity> GetCaChe()
        {
            return base.GetList();
        }

        #endregion
        
    }
}